/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.jr2tecnologia.model;

import br.com.jr2tecnologia.model.entity.Page;
import br.com.jr2tecnologia.model.persistence.DAOFactory;
import br.com.jr2tecnologia.model.repository.PageRepository;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author ronildo
 */

@Stateless
public class PagePersistence implements PagePersistenceLocal{
    
    @PersistenceContext
    private EntityManager em;
    private PageRepository pageRepository;
    
    @PostConstruct
    public void initialize(){
        pageRepository = DAOFactory.getPageRepository(em);
    }

    public Page findById(Long id) {
        return pageRepository.findById(id);
    }

    public Page findByName(String name) {
        return pageRepository.findByName(name);
    }

    public List<Page> list(Page page) {
        return pageRepository.list(page);
    }

    public List<Page> listAll() {
        return pageRepository.listAll();
    }
}
